﻿''' <summary>
''' This class defines a metric to be measured. Metrics are data subelements
''' that can be found in the data returned by a WMI query.
''' </summary>
''' <remarks></remarks>
Public Class WMIMetric

    ''' <summary>
    ''' The metric name. Used to lookup the actual metric.
    ''' </summary>
    ''' <remarks></remarks>
    Protected m_name As String

    ''' <summary>
    ''' If the metric is to have lookups, they are stored here.
    ''' </summary>
    ''' <remarks></remarks>
    Protected m_lookups As List(Of WMILookup)

    ''' <summary>
    ''' Get/set the metric name.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Name() As String
        Get
            Return m_name
        End Get
        Set(ByVal value As String)
            m_name = value
        End Set
    End Property

    ''' <summary>
    ''' Get/set the list of lookups.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Lookups() As List(Of WMILookup)
        Get
            Return m_lookups
        End Get
        Set(ByVal value As List(Of WMILookup))
            m_lookups = value
        End Set
    End Property

    ''' <summary>
    ''' Default class constructor.
    ''' </summary>
    ''' <param name="Name">Metric name.</param>
    ''' <remarks></remarks>
    Public Sub New(ByVal Name As String)

        Me.Name = Name
        m_lookups = New List(Of WMILookup)

    End Sub

    ''' <summary>
    ''' Add a lookup for this metric.
    ''' </summary>
    ''' <param name="o"></param>
    ''' <remarks></remarks>
    Public Sub AddLookup(ByVal o As WMILookup)

        m_lookups.Add(o)

    End Sub

    ''' <summary>
    ''' Find the lookup that represents the given value.
    ''' </summary>
    ''' <param name="val"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetLookup(ByVal val As String) As WMILookup

        For i As Integer = 0 To m_lookups.Count - 1
            If m_lookups(i).Value = val Then
                Return m_lookups(i)
            End If
        Next
        Return Nothing

    End Function

End Class
